<?php

//Coded by Jonathan Gorard, 2012
//Part of The Matrix Unplugged, All Rights Reserved

	include "config.php";
	global $_CONFIG;
	
	if($_GET['code'] != $_CONFIG['code']) {
		die("");
	}

	define("MONO_ON", 1);
	require "class/class_db_{$_CONFIG['driver']}

.php";
$db=new database;
$db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq)){
	$set[$r['conf_name']]=$r['conf_value'];
}

//brave update
$query="UPDATE users SET brave=brave+((maxbrave/10)+0.5) WHERE brave<maxbrave ";
$query2="UPDATE users SET brave=maxbrave WHERE brave>maxbrave";
$query3="UPDATE users SET hp=hp+(maxhp/3) WHERE hp<maxhp";
$query4="UPDATE users SET hp=maxhp WHERE hp>maxhp";
$db->query($query);
$db->query($query2);
$db->query($query3);
$db->query($query4);
//enerwill update
$query="UPDATE users SET energy=energy+(maxenergy/(12.5)) WHERE energy<maxenergy AND donatordays=0";
$query5="UPDATE users SET energy=energy+(maxenergy/(6)) WHERE energy<maxenergy AND donatordays>0";
$query2="UPDATE users SET energy=maxenergy WHERE energy>maxenergy";
$query3="UPDATE users SET will=will+10 WHERE will<maxwill";
$query4="UPDATE users SET will=maxwill WHERE will>maxwill";
$db->query($query);
$db->query($query5);
$db->query($query2);
$db->query($query3);
$db->query($query4);

if($set['validate_period'] == 5 && $set['validate_on']){
	$db->query("UPDATE users SET verified=0");
}


if($set['validate_period'] == 15 && $set['validate_on'] && in_array(date('i'),array("00", "15", "30", "45"))){
	$db->query("UPDATE users SET verified=0");
}

?>
